package com.shp.service.serviceImpl;

import com.shp.dao.NeedDao;
import com.shp.pojo.Need;
import com.shp.service.NeedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Description:
 *
 * @author zwl
 * @version 1.0
 * @date 2020/3/6 16:52
 */
@Service(value = "needService")
public class NeedServiceImpl implements NeedService {

    @Autowired
    private NeedDao needDao;

    /**
     * 查询所有的求购信息
     *
     * @return List<Need>
     */
    @Override
    public List<Need> getNeedAll() {
        return needDao.getNeedAll();
    }

    /**
     * 保存一条求购信息
     *
     * @param need Need
     * @return true代表保存成功，false代表保存失败
     */
    @Override
    public boolean saveNeed(Need need) {
        if(needDao.insert(need) == 1){
            return true;
        }
        return false;
    }

    /**
     * 获取求购信息地个数
     *
     * @param status 状态
     * @return 个数
     */
    @Override
    public int getNeedNum(int status) {
        return needDao.getNeedNum(status);
    }
}
